<template>
  <div>
    <el-card class="box-card">
      <el-descriptions title="员工信息">
        <el-descriptions-item label="姓名">{{
          form.name
        }}</el-descriptions-item>
        <el-descriptions-item label="工号">{{ form._id }}</el-descriptions-item>
        <el-descriptions-item label="证件号码">{{
          form.sid
        }}</el-descriptions-item>
        <el-descriptions-item label="手机号">{{
          form.phone
        }}</el-descriptions-item>
        <el-descriptions-item label="工作性质">{{
          form.nature
        }}</el-descriptions-item>
        <el-descriptions-item label="人员状态">{{
          form.state
        }}</el-descriptions-item>
        <el-descriptions-item label="部门">{{
          form.stationId.name
        }}</el-descriptions-item>
        <el-descriptions-item label="岗位">{{
          form.organId.name
        }}</el-descriptions-item>
        <el-descriptions-item label="入职日期">{{
          form.entry | Day
        }}</el-descriptions-item>
        <el-descriptions-item label="转正日期">{{
          form.formalTime | Day
        }}</el-descriptions-item>
      </el-descriptions>
    </el-card>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>确认离职</span>
      </div>
      <el-form ref="form" :model="form" label-width="180px">
        <el-form-item label="申请日期：">
          <el-col :span="12">
            <el-date-picker
              v-model="form.applicationTime"
              type="date"
              placeholder="选择日期"
              style="width: 83%"
            >
            </el-date-picker>
          </el-col>
        </el-form-item>

        <el-form-item label="实际离职日期：">
          <el-col :span="12">
            <el-date-picker
              v-model="form.leaveTime"
              type="date"
              placeholder="选择日期"
              style="width: 83%"
            >
            </el-date-picker>
          </el-col>
        </el-form-item>

        <el-form-item label="薪资结算日期：">
          <el-col :span="12">
            <el-date-picker
              v-model="form.endTime"
              type="date"
              placeholder="选择日期"
              style="width: 83%"
            >
            </el-date-picker>
          </el-col>
        </el-form-item>

        
          <el-form-item label="离职原因：">
            <el-col :span="12">
            <el-input v-model="form.why" style="width: 83%"></el-input>
            </el-col>
          </el-form-item>
        

        <el-form-item label="离职原因说明：">
          <el-input
            type="textarea"
            v-model="form.why"
            placeholder="请输入"
          ></el-input>
        </el-form-item>
        <el-form-item label="备注：">
          <el-input
            type="textarea"
            v-model="form.ps"
            placeholder="请输入"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="go()">返回</el-button>
          <el-button type="primary" @click="onSubmit">离职</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "VueSalarysysOutgoing",

  data() {
    return {
      app: "",
      form: {
        name: "",
        sex: "",
        // 组织 部门
        stationId: "",
        // 岗位
        organId: "",
        phone: "",
        // 工号———_id
        _id: "",
        // 证件号
        sid: "",
        // 工作性质 ———— 全职 临时
        nature: "",
        // 入职时间
        entry: "",
        // 状态————正式 试用 待离职 已离职
        state: "",
        // 转正时间
        formalTime: "",
        // 试用期
        try: "",
        // 申请离职日期
        applicationTime: "",
        // 离职日期
        leaveTime: "",
        // 薪资结算日期
        endTime: "",
        // 离职原因
        why: "",
        // 离职原因说明
        whyps: "",
        account: "", //账号
        email: "", //邮件
        status: "", //状态
        role_id: "", //角色
      },
    };
  },

  mounted() {
    this.getData(this.$route.query.id);
  },

  methods: {
    async getData(id) {
      let {
        data: { data },
      } = await this.$axios.get("/organ/getConverted?id=" + id);
      let apps = new Date(data[0].leaveTime);
      apps.setDate(apps.getDate() - 30);
      let end = new Date(data[0].leaveTime);
      end.setDate(end.getDate() + 15);
      this.form = data[0];
      this.form.applicationTime = apps;
      this.form.endTime = end;
      console.log(this.form, "apppppppp");
    },
    go(){
      window.history.go(-1)
    }
  },
};
</script>

<style lang="scss" scoped>
.box-card {
  margin-bottom: 20px;
}
</style>